package inits

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"zy12/config"
	"zy12/global"
)

func ExampleClient() {
	Conf := config.Conf.Redis
	global.Rdb = redis.NewClient(&redis.Options{
		Addr:     Conf.Addr,
		Password: Conf.Password, // no password set
		DB:       Conf.DB,       // use default DB
	})

	err := global.Rdb.Set(context.Background(), "key", "value", 0).Err()
	if err != nil {
		panic(err)
	}
	fmt.Println("redis连接成功")
}
